package com.wsc.juc_001.c_006;

/**
 * 1.实现runnable接口，但是方法用Synchronized修饰：线程不按顺序执行，但是count--顺序输出
 */
public class Synchronized_06 implements Runnable{
    public  volatile int count = 100;

    @Override
    public synchronized void run() {
        count--;
        System.out.println(Thread.currentThread().getName() + " count =" +count);
    }

    public static void main(String[] args) {
        Synchronized_06 synchronized_06 = new Synchronized_06();
        for (int i = 0; i <100 ; i++) {
            new Thread(synchronized_06).start();
        }

    }


}
